"""
内容:已登录账号,从首页点击搜索框输入商品信息进行搜索
作者:刘芳
"""
#引入模块
from ECshop.common.base import Base,create_browser_op
import time

#创建一个搜索类
class PageFirstSearch(Base):

    #定义属性
    search_box=("name","keywords")
    search_button=("name","imageField")
    current_position="div[class='path']>div"
    url="http://localhost:8080/ecshop"

    #定义方法
    #进入登录后的首页
    def page_first_page_search_open_web(self):
        self.base_open_web(self.url)

    #点击搜索框输入服装
    def page_first_page_search_input_content(self,your_content):
        self.base_input_content(self.search_box,your_content)

    #点击搜索按钮
    def page_first_page_search_click(self):
        self.base_click(self.search_button)

    #获取当前位置的文本内容
    def page_first_page_search_get_text(self):
        return self.base_get_text1(self.current_position)

    #退出
    def page_first_page_search_quit(self):
        self.base_quit()

if __name__ == '__main__':
    pf1=PageFirstSearch(create_browser_op(r'C:\Users\86184\AppData\Local\Google\Chrome\User Data'))
    pf1.page_first_page_search_open_web()
    pf1.page_first_page_search_input_content("手机")
    pf1.page_first_page_search_click()
    time.sleep(3)
    print(pf1.page_first_page_search_get_text())
    pf1.page_first_page_search_quit()

